home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 January / EnterCD 0105.iso / Internet / Norton Internet Security 2005 / NIS_Retail.EXE / Setup / ISCommon / APP / ALEScan.exe / HTML / WIZ-ALES.JS < prev    next >
Encoding:
Text File  |  2004-08-31  |  15.7 KB  |  666 lines

  1. ////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // PRODUCT: Norton Internet Security/Symantec Desktop Firewall
  4. //
  5. // NAME:    wiz-ALEs.js (Javascript file for wiz-ALEs.HTM)
  6. //
  7. // Copyright (c) 2001 by Symantec Corporation. All rights reserved.
  8. //
  9. ////////////////////////////////////////////////////////////////////////////////////////////
  10.  
  11. IE4 = document.all;
  12. var g_LocationAwarenessOffText;
  13. var g_iLocationList = null;
  14. var g_sProductIcon = "res://NisRes.dll/105";
  15. var g_sProductVersion = "8.0";
  16. var g_RLevelStatus =  null;
  17. ///////////////////////////////////////////////////////
  18. /////////new alert params /////////////////////////////
  19. ///////////////////////////////////////////////////////
  20. //icon:
  21. // 0 = no icon
  22. // 1 = error
  23. // 2 = question
  24. // 3 = alert
  25. // 4 = info
  26. //
  27. //buts:
  28. // 0 = ok
  29. // 1 = ok, cancel
  30. // 2 = abort, retry, cancel
  31. // 3 = yes, no, cancel
  32. // 4 = yes, no
  33. // 5 = retry, cancel
  34. //
  35. //defbut
  36. // 0 = first
  37. // 1 = second
  38. // 2 = third
  39. //
  40. //mods:
  41. // 0 = app modal
  42. // 1 = system modal
  43. function newAlert(mess, title, icon, buts, defbut, mods)
  44. {
  45.     if(IE4)
  46.         makeMsgBox(title, mess, icon, buts, defbut, mods)
  47.     else
  48.         alert(mess);
  49. }
  50.  
  51. function OnLoad()
  52. {
  53.     g_RLevelStatus = new ActiveXObject("RLevel.NISStatusInfo");
  54.     
  55.     var iFirewallSettings = new ActiveXObject("ccFWSettg.FirewallSettings");
  56.     g_iLocationList = iFirewallSettings.Locations;
  57.     g_LocationAwarenessOffText = LocationAwarenessIsOffText.innerText;
  58.     
  59.     // Set the property bag before calling into ACDisp
  60.     SetFWPropertyBag();
  61.     
  62.     FoundList.SetOnCheckedChangedCallback(foundList_OnCheckStateChanged);
  63.  
  64.     FoundList.UseALEList = true;
  65.     
  66.     FoundList.RefreshRules();
  67.         
  68.     FoundList.UseRegistry = false;
  69.  
  70.     // Now pass in a location object.
  71.     var g_iLocation = g_iLocationList.GetDefaultItem();
  72.     
  73.     FoundList.FilterByLocation = g_iLocation;
  74. }
  75.  
  76. function SetFWPropertyBag()
  77. {
  78.     // Create property bag object to pass to FWUI.
  79.     try
  80.     {
  81.         var fwUIPropertyBag = new ActiveXObject("fwUI.VarBstrCol");
  82.  
  83.         // Retrive the product name and current user type.
  84.         var sProductName = UserManager.ProductName;
  85.         var sCurrentUserType = UserManager.CurrentUserType;
  86.  
  87.  
  88.             // Retrieve product type and help path.
  89.         var sProductType = UserManager.ProductType;
  90.         var sHelpPath = UserManager.HelpPath;
  91.  
  92.         if(sProductType == "PT_SCF")
  93.         {
  94.             g_iProductType = FWUI_PRODUCT_SCF;
  95.             sHelpPath = sHelpPath + "\\SCF.chm";
  96.         }
  97.         else
  98.         {
  99.             g_iProductType = FWUI_PRODUCT_NIS;
  100.             sHelpPath = sHelpPath + "\\SymHelp.chm";
  101.         }
  102.  
  103.         // Fill in the FW property bag.
  104.  
  105.         // Fill in product name.
  106.         fwUIPropertyBag.Add(ProductDisplayName);
  107.         fwUIPropertyBag(ProductDisplayName) = sProductName;
  108.  
  109.         // Fill in product type.
  110.         fwUIPropertyBag.Add(ProductType);
  111.         fwUIPropertyBag(ProductType) = g_iProductType;
  112.  
  113.         // Fill in product version.
  114.         fwUIPropertyBag.Add(ProductVersion);
  115.         fwUIPropertyBag(ProductVersion) = g_sProductVersion;
  116.  
  117.         // Fill in path to product icon.
  118.         fwUIPropertyBag.Add(ProductIconPath);
  119.         fwUIPropertyBag(ProductIconPath) = g_sProductIcon;
  120.  
  121.         // Fill in path to help file.
  122.         fwUIPropertyBag.Add(ProductHelpPath);
  123.         fwUIPropertyBag(ProductHelpPath) = sHelpPath;
  124.  
  125.         // Fill in the Context ID for the FW help.
  126.         fwUIPropertyBag.Add(RulesHelpID);
  127.         fwUIPropertyBag(RulesHelpID) = RuleSummary;
  128.  
  129.         fwUIPropertyBag.Add(RuleEditActionHelpID);
  130.         fwUIPropertyBag(RuleEditActionHelpID) = RuleEditAction;
  131.  
  132.         fwUIPropertyBag.Add(RuleEditIPHelpID);
  133.         fwUIPropertyBag(RuleEditIPHelpID) = RuleEditIP;
  134.  
  135.         fwUIPropertyBag.Add(RuleEditDirectionHelpID);
  136.         fwUIPropertyBag(RuleEditDirectionHelpID) = RuleEditDirection;
  137.  
  138.         fwUIPropertyBag.Add(RuleEditPortsHelpID);
  139.         fwUIPropertyBag(RuleEditPortsHelpID) = RuleEditPorts;
  140.  
  141.         fwUIPropertyBag.Add(RuleEditLocationsHelpID);
  142.         fwUIPropertyBag(RuleEditLocationsHelpID) = RuleEditLocations;
  143.  
  144.         fwUIPropertyBag.Add(RuleEditLoggingHelpID);
  145.         fwUIPropertyBag(RuleEditLoggingHelpID) = RuleEditLogging;
  146.  
  147.         fwUIPropertyBag.Add(RuleEditTitleHelpID);
  148.         fwUIPropertyBag(RuleEditTitleHelpID) = RuleEditTitle;
  149.  
  150.         fwUIPropertyBag.Add(AdaptersHelpID);
  151.         fwUIPropertyBag(AdaptersHelpID) = Adapters;
  152.  
  153.         fwUIPropertyBag.Add(ICMPHelpID);
  154.         fwUIPropertyBag(ICMPHelpID) = ICMP;
  155.  
  156.         fwUIPropertyBag.Add(SpecifyComputerHelpID);
  157.         fwUIPropertyBag(SpecifyComputerHelpID) = IPPopup;
  158.  
  159.         fwUIPropertyBag.Add(IPExclusionHelpID);
  160.         fwUIPropertyBag(IPExclusionHelpID) = IPExclusions;
  161.  
  162.         fwUIPropertyBag.Add(SignatureHelpID);
  163.         fwUIPropertyBag(SignatureHelpID) = SignatureExclusions;
  164.  
  165.         // Fill in CurrentUserType
  166.         fwUIPropertyBag.Add(CurrentUserType);
  167.         fwUIPropertyBag(CurrentUserType) = sCurrentUserType;
  168.  
  169.         // Fill in whether Parental Control is install or not.
  170.         fwUIPropertyBag.Add(ParentalControl);
  171.  
  172.         if (g_RLevelStatus.AreAccountsInstalled)
  173.             fwUIPropertyBag(ParentalControl) = true;
  174.         else
  175.             fwUIPropertyBag(ParentalControl) = false;
  176.  
  177.         // Fill in whether Admin Rule feature is enable or not.
  178.         fwUIPropertyBag.Add(AdminRule);
  179.         fwUIPropertyBag(AdminRule) = UserManager.ProductFeature(4);
  180.  
  181.         //This should be the first thing that we do before calling into ACDisp.
  182.         FoundList.Init(fwUIPropertyBag);
  183.     }
  184.     catch(e)
  185.     {
  186.     }
  187. }
  188.  
  189. function driveList_OnSpace(nRow)
  190. {
  191.     //
  192.     // Swap the state of the check box for this item
  193.     //
  194.     var CheckBox = driveList.GetCellPtr(nRow, 0).children[0];
  195.     CheckBox.checked = !CheckBox.checked;
  196. }
  197.  
  198. function initDriveList()
  199. {
  200.     driveList.OnSpace = driveList_OnSpace;
  201.     driveList.DeleteAllRows();
  202.     driveList.SetColumnCount(2);
  203.     driveList.SetColumnWidth(0, "50px");
  204.     driveList.SetColumnWidth(1, "83px");
  205.  
  206.     var szDrives = NetScan.DriveList;
  207.  
  208.     for(var i = 0; i < szDrives.length; ++i)
  209.     {
  210.         var pRow = driveList.InsertRow(-1);
  211.         driveList.SetCellTextPtr(pRow, 0, "<input type=\"checkbox\" checked>");
  212.         driveList.SetCellTextPtr(pRow, 1, szDrives.substring(i, i+1) + ":\\");
  213.     }
  214.  
  215.     driveList.SetOnClickHandler(CheckBox_OnClick);
  216. }
  217.  
  218. function CheckBox_OnClick()
  219. {
  220.     // Get a count of checked items... if zero are checked, disable the next btn
  221.     var nCount = driveList.GetRowCount();
  222.  
  223.     var nChecked = 0;
  224.     for(var nRow = 0; nRow < nCount; ++nRow)
  225.     {
  226.         var CheckBox = driveList.GetCellPtr(nRow, 0).children[0];
  227.         if(CheckBox.checked)
  228.         {
  229.             nChecked++;
  230.         }
  231.     }
  232.  
  233.     if(nChecked == 0)
  234.         NextBtn.disabled = true;
  235.     else
  236.         NextBtn.disabled = false;
  237. }
  238.  
  239. function saveDriveList()
  240. {
  241.     var nCount = driveList.GetRowCount();
  242.  
  243.     szDrives = "";
  244.     for(var nRow = 0; nRow < nCount; ++nRow)
  245.     {
  246.         var CheckBox = driveList.GetCellPtr(nRow, 0).children[0];
  247.         if(CheckBox.checked)
  248.         {
  249.             szDrives += driveList.GetCellPtr(nRow, 1).innerText.substring(0, 1);
  250.         }
  251.     }
  252.  
  253.     NetScan.DriveList = szDrives;
  254. }
  255.  
  256. function NextBtn_OnClick()
  257. {
  258. // Find the active page, back to front (if we are not disabled)
  259.     if(PageD.style.display == "")
  260.     {
  261.         ConfigInfo.AleScanRun = true;
  262.         returnValue = "";
  263.         AleWiz_Body.style.cursor = "wait";
  264.         BackBtn.disabled = true;
  265.         FinishBtn.disabled = true;
  266.         Cancel.disabled = true;
  267.         locationSelectAll.disabled = true;
  268.         locationSelectNone.disabled = true;
  269.         locationList.Enabled(false);
  270.         locationList.LTable.style.cursor = "wait";
  271.         EnableCloseButton(false);
  272.  
  273.         // save the items in the list
  274.         var iLocationList = UILocation_GetSelectedLocations();
  275.         FoundList.AddALEScanLocation(iLocationList);
  276.         FoundList.MergeItemsAsync(OnMergeItemsComplete);
  277.     }
  278.  
  279.     if(PageC.style.display == "")
  280.     {
  281.         PageC.style.display = "none";
  282.         PageD.style.display = "";
  283.  
  284.         //set location awareness text
  285.         var bLAIsOn = g_RLevelStatus.LocationAwarenessEnabled;
  286.         if(bLAIsOn)
  287.             LocationAwarenessIsOffText.innerText = " ";
  288.         else 
  289.             LocationAwarenessIsOffText.innerText = g_LocationAwarenessOffText;
  290.         initLocationList();
  291.         
  292.         FixBtnText(true);
  293.         window.focus();
  294.     }
  295.  
  296.     if(PageB.style.display == "")
  297.     {
  298.         // setup PageC
  299.         PageB.style.display = "none";
  300.         PageC.style.display = "";
  301.         NextBtn.disabled = true;
  302.  
  303.         window.focus();
  304.         
  305.         // update the foundlist after it's had a chance to be created
  306.         window.setTimeout("UpdateFoundList()",1);
  307.     }
  308.  
  309.     if(PageA.style.display == "")
  310.     {
  311.         PageA.style.display = "none";
  312.         PageB.style.display = "";
  313.  
  314.         // setup PageB
  315.         NextBtn.disabled = true;
  316.         Cancel.disabled = true;
  317.         StopBtn.disabled = false;
  318.         EnableCloseButton(false);
  319.  
  320.         ScanDone.style.display = "none";
  321.         ScanStopped.style.display = "none"
  322.         Scanning.style.display = "";
  323.         Filename.style.display = "";
  324.         ScanFound.innerHTML = "0";
  325.         SetProgress(0);
  326.         pctdone.innerHTML = "0";
  327.         pctdone_text.style.display = "";
  328.  
  329.         saveDriveList();
  330.         g_bScanStarted = true;
  331.         NetScan.StartScan(FoundList);
  332.  
  333.         FixBtnText(false);
  334.     }
  335. }
  336.  
  337. function UpdateFoundList()
  338. {
  339.     FoundList.RefreshALEList();
  340.     FoundList_OnSelect();
  341. }
  342.  
  343. function OnMergeItemsComplete(result)
  344. {
  345.     if(HandleAleScanError(result, 1014, 1))
  346.     {
  347.         // This means that the user needs to be sent back to 
  348.         // PageC to de-select some applications.
  349.         if(PageA.style.display == "")
  350.             PageA.style.display = "none"
  351.         if(PageB.style.display == "")
  352.             PageB.style.display = "none"
  353.         if(PageD.style.display == "")
  354.             PageD.style.display = "none"
  355.         
  356.         PageC.style.display = "";
  357.  
  358.         window.focus();
  359.         
  360.         // Reset the values on the location page.
  361.         locationSelectAll.disabled = false;
  362.         locationSelectNone.disabled = false;
  363.         locationList.Enabled(true);
  364.         locationList.LTable.style.cursor = "";
  365.         // re-enable the items in the list
  366.         var iLocationList = UILocation_GetSelectedLocations();
  367.         var nLocations = iLocationList.ItemCount;
  368.         for(var i = 0; i < nLocations; i++)
  369.         {
  370.             var checkbox = locationList.GetCellPtr(i,0);
  371.             checkbox.disabled = false;
  372.         }
  373.  
  374.         // Reset the buttons.
  375.         FinishBtn.disabled = false;
  376.         NextBtn.disabled = false;
  377.         BackBtn.disabled = false;
  378.         Cancel.disabled = false;
  379.         FixBtnText(false);
  380.         EnableCloseButton(true);
  381.  
  382.         // And the cursor
  383.         AleWiz_Body.style.cursor = "";
  384.     }
  385.     else
  386.     {
  387.         AleWiz_Body.style.cursor = "";
  388.         window.navigate("res://closeme.xyz");
  389.     }
  390. }
  391.  
  392. function SetProgress(nPct)
  393. {
  394.     SetProgressImpl(ProgDone,ProgRemain,pctdone,nPct);
  395. }
  396.  
  397. function SetProgressImpl(complete,remaining,text,nPct)
  398. {
  399.     // We must special case 0 otherwise we get "invalid property"... arrrgggg!
  400.     var nRemain = 100 - nPct;
  401.     text.innerHTML = nPct;
  402.     
  403.     if(nPct > 0)
  404.     {
  405.         complete.style.display = "";
  406.         complete.width = nPct + "%";
  407.     }
  408.     else
  409.     {
  410.         complete.style.display = "none";
  411.     }
  412.     
  413.     if(nRemain > 0)
  414.     {
  415.         remaining.style.display = "";
  416.         remaining.width = nRemain + "%";
  417.     }
  418.     else
  419.     {
  420.         remaining.style.display = "none";
  421.     }
  422. }
  423.  
  424. function Elipse_Path(nMaxLen, szPath)
  425. {
  426.     var szItems = szPath.split("\\");
  427.     var nItem = 0;
  428.     var nLastStart = 1;
  429.     var szOutput = szPath;
  430.     while(szOutput.length > nMaxLen)
  431.     {
  432.         szOutput = szItems[0];
  433.         szOutput = szOutput + "\\" + "...";
  434.         
  435.         for(nItem = nLastStart; nItem < szItems.length; nItem++)
  436.         {
  437.             szOutput = szOutput + "\\" + szItems[nItem];            
  438.         }
  439.         
  440.         nLastStart++;
  441.     }
  442.     
  443.     return szOutput;
  444. }
  445.  
  446. function CheckUserType()
  447. {
  448.     var type = UserManager.CurrentUserType;
  449.     var product = UserManager.ProductType;
  450.  
  451.     if((product == "PT_SCF") || (product == "PT_NPF") || (product == "PT_SDF"))
  452.     {
  453.         if(type == "UT_RESTRICTED")
  454.         {
  455.             newAlert(StrID("ALEScanAdministrator"), UserManager.AppTitle, 3, 0, 0, 0);
  456.             window.navigate("res://closeme.xyz");
  457.         }
  458.     }
  459.         else
  460.     {
  461.         if(type != "UT_SUPERVISOR")
  462.         {
  463.             newAlert(StrID("ALEScanSupervisor"), UserManager.AppTitle, 3, 0, 0, 0);
  464.             window.navigate("res://closeme.xyz");
  465.         }
  466.     }
  467. }
  468.  
  469. function OnAdd()
  470. {
  471.     FoundList.Add();
  472. }
  473.  
  474. function OnModify()
  475. {
  476.     FoundList.Modify();
  477. }
  478.  
  479. function OnCheckAll()
  480. {
  481.     FoundList.SelectAll();
  482. }
  483.  
  484. function OnUncheckAll()
  485. {
  486.     FoundList.UnselectAll();
  487. }
  488.  
  489. function foundList_OnCheckStateChanged(bAnySelected)
  490. {
  491.     NextBtn.disabled = !bAnySelected;
  492. }
  493.  
  494. function OnKeyDownHandler()
  495. {
  496.     // Last Control Tab over to the <back, next, close> button.
  497.     var VK_ESCAPE = 27;
  498.  
  499.     if (window.event.keyCode == VK_ESCAPE && !Cancel.disabled)
  500.     {
  501.         // Escape key.. We want to exit out of the wizard..
  502.         window.navigate("res://closeme.xyz");
  503.  
  504.     }
  505.     
  506. }
  507.  
  508. function initLocationList()
  509. {
  510.     // Setup the list control
  511.     locationList.SetTableClass("ListBoxClass");
  512.     locationList.OnClick    = locationList_OnClick;
  513.     locationList.OnDblClick = locationList_OnDblClick;
  514.     locationList.OnSpace    = locationList_OnSpace;
  515.  
  516.     locationList.DeleteAllRows();
  517.     locationList.SetColumnCount(2);
  518.     locationList.SetColumnWidth(0, "15px");
  519.     locationList.SetColumnWidth(1, "100px");
  520.  
  521.     // populate list
  522.     AleWiz_Body.style.cursor = "wait";
  523.  
  524.     try
  525.     {
  526.         var nLocations = g_iLocationList.ItemCount;
  527.         for (var i=0; i<nLocations; i++)
  528.         {
  529.             var iLocation = g_iLocationList.GetItem(i);
  530.         
  531.             var pRow = locationList.InsertRow(-1);
  532.             var Enabled = "checked=yes";
  533.             
  534.             var checkboxString = "<input type=checkbox " + Enabled + ">";
  535.             locationList.SetCellTextPtr(pRow, 0, checkboxString);
  536.             
  537.             var locationName = iLocation.Name;
  538.             var divID = "";
  539.             if(iLocation.Active)
  540.             {
  541.                 locationName += "  ";
  542.                 locationName += StrID("Active");
  543.                 divID = "id='ACTIVE ITEM.  DO NOT MOVE THIS STRING OUT OF THE CODE.'"
  544.             }
  545.             var TextToAdd = "<div " + divID + " style='margin-top:6;margin-bottom:6'>" + locationName + "</div>";
  546.             locationList.SetCellTextPtr(pRow, 1, TextToAdd);
  547.         }
  548.     }
  549.     catch(e)
  550.     {
  551.     }
  552.     
  553.     AleWiz_Body.style.cursor = "";
  554. }
  555.  
  556. function locationList_OnSpace()
  557. {
  558.     var nCurSel = locationList.GetCurSel();
  559.     var bEnable = false;
  560.  
  561.     if(nCurSel < 0)
  562.     {
  563.         return;    
  564.     }
  565.  
  566.     // Swap the state of the check box for this item
  567.     var CheckBox = locationList.GetCellPtr(nCurSel, 0).children[0];
  568.     CheckBox.checked = !CheckBox.checked;
  569.     
  570.     UILocation_UpdateNextButtonState();
  571. }
  572.  
  573. function locationList_OnClick()
  574. {
  575.     UILocation_UpdateNextButtonState();
  576. }
  577.  
  578. function UILocation_UpdateNextButtonState()
  579. {
  580.     var iLocationList = UILocation_GetSelectedLocations();
  581.  
  582.     if(iLocationList.ItemCount > 0)
  583.     {
  584.         FinishBtn.disabled = false;
  585.     }
  586.     else
  587.     {
  588.         FinishBtn.disabled = true;
  589.     }
  590. }
  591.  
  592. function locationList_OnDblClick()
  593. {
  594.     var nCurSel = locationList.GetCurSel();
  595.     var bEnable = false;
  596.  
  597.     if(nCurSel < 0)
  598.     {
  599.         return;    
  600.     }
  601.  
  602.     // Swap the state of the check box for this item
  603.     var CheckBox = locationList.GetCellPtr(nCurSel, 0).children[0];
  604.     CheckBox.checked = !CheckBox.checked;
  605.     
  606.     UILocation_UpdateNextButtonState();
  607. }
  608.  
  609. function UILocation_SelectAll()
  610. {
  611.     for(var i = locationList.GetRowCount(); i > 0; i--)
  612.     {
  613.         var CheckBox = locationList.GetCellPtr(i - 1, 0).children[0];
  614.         CheckBox.checked = true;
  615.     }
  616.     UILocation_UpdateNextButtonState()
  617. }
  618.  
  619. function UILocation_DeselectAll()
  620. {
  621.     for(var i = locationList.GetRowCount(); i > 0; i--)
  622.     {
  623.         var CheckBox = locationList.GetCellPtr(i - 1, 0).children[0];
  624.         CheckBox.checked = false;
  625.     }
  626.     UILocation_UpdateNextButtonState()
  627. }
  628.  
  629. function UILocation_GetSelectedLocations()
  630. {
  631.     var iLocationList = new ActiveXObject("ccFWSettg.LocationList");
  632.     
  633.     for(var i = locationList.GetRowCount(); i > 0; i--)
  634.     {
  635.         var CheckBox = locationList.GetCellPtr(i - 1, 0).children[0];
  636.         var bChecked = CheckBox.checked;
  637.         var div = locationList.GetCellPtr(i-1, 1).children[0];
  638.         var sLocation = div.innerText;    
  639.         if(bChecked)
  640.         {
  641.             if(div.id == "ACTIVE ITEM.  DO NOT MOVE THIS STRING OUT OF THE CODE.")
  642.             {
  643.                 var sTmp = sLocation.slice(0, sLocation.lastIndexOf(StrID("Active")));
  644.                 sLocation = sTmp;
  645.             }
  646.             sLocation = trim(sLocation);
  647.             iLocationList.AddItem(g_iLocationList.GetItem(i-1));
  648.         }
  649.     }
  650.     return iLocationList;
  651. }
  652.  
  653. function UserManager_OnFREIntegratorStart()
  654. {
  655.     if(g_bScanStarted)
  656.         StopBtn_OnClick();
  657.  
  658.     window.navigate('res://closeme.xyz');
  659. }
  660.  
  661. function EnableCloseButton(bEnabled)
  662. {
  663.     //turn off webWnd's close button
  664.     var webWnd = window.external.ObjectArg;
  665.     webWnd.CloseButton = bEnabled;
  666. }